package com.ljs.view.panel
{
	import com.ljs.control.MainContent;
	import com.ljs.control.MainControl;
	import com.ljs.net.Packet;
	import com.ljs.net.login.CSLoginPacket;
	import com.ljs.net.login.LogInData;
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.text.TextField;

	public class LoginPanel extends MovieClip
	{
		private var _nameText:TextField;
		private var _passWordText:TextField;
		private var _loginBtn:MovieClip;
		private var _control:MainControl;
		private var _content:MainContent;
		public function LoginPanel()
		{
			init();
		}
		
		public function setContent(c:MainContent)
		{
			_content=c;
		}
		
		private function init()
		{
			_nameText=getChildByName("tfAccount") as TextField;
			_passWordText=getChildByName("tfPassWord") as TextField;
			_loginBtn=getChildByName("btLogin") as MovieClip;
			_loginBtn.addEventListener(MouseEvent.CLICK,onClick);
		}
		
		public function setControl(c:MainControl)
		{
			_control=c;
		}
		
		private function onClick(e:MouseEvent)
		{
			var CSP:CSLoginPacket=new CSLoginPacket;
			CSP.getData().userName=_nameText.text;
			CSP.getData().password=_passWordText.text;
			_content.net.sendPacket(CSP);
			_control.sendPacket();
		}
	}
}